package com.luyu.controller;


import com.luyu.group.AgeGroup;
import com.luyu.group.NameGroup;
import com.luyu.req.*;
import jakarta.validation.Valid;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/")
public class TestController {


    @PostMapping("/param")
    public String validParameter(@RequestBody @Validated  User req){
        return "success";
    }

    @PostMapping("/group")
    public String validGroup(@RequestBody @Validated(value = {NameGroup.class, AgeGroup.class}) UserGroup req) {
        return "success";
    }


    @PostMapping("/error/msg")
    public String validInfo(@RequestBody @Validated User req) {
        return "success";
    }

    @PostMapping("/cascade")
    public String validCascadeInfo(@RequestBody @Validated UserCascade req) {
        return "success";
    }

    @PostMapping("/sequence")
    public String validGroupSequence(@RequestBody @Valid UserGroupSequenceReq req) {
        return "success";
    }


    @PostMapping("/sequence/provider")
    public String validGroupSequenceProvider(@RequestBody @Validated UserGroupSequenceProviderReq req) {
        return "success";
    }

    @PostMapping("/group/convert")
    public String convertGroup(@RequestBody @Validated UserCascade req) {
        return "success";
    }

    @PostMapping("/anno/recombination")
    public String validRecombinationAnon(@RequestBody @Validated UserWithEmail req) {
        return "success";
    }


    @PostMapping("/anno/custom")
    public String validCustomAnno(@RequestBody @Validated UserWithEmail req) {
        return "success";
    }


    @PostMapping("/custom/anno/validator")
    public String validCustomConstraintValidator(@RequestBody @Validated UserWithEmail req) {
        return "success";
    }


}
